package org.soar.views;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.BaseAdapter;

import org.soar.SoarApplication;

public abstract class SoarDataAdapter extends BaseAdapter {
	protected List<Map> data;
	protected LayoutInflater inflater;
	protected Context context;
	
	public SoarDataAdapter(List<Map> data,Context context) {
		this.context = context;
		this.data = data;
		inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		((SoarApplication)context.getApplicationContext()).getInjector().injectMembers(this);
	}

	@Override
	public int getCount() {
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		return data.get(position);
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}
	
	public void addItem(Map map){
		this.data.add(map);
		this.notifyDataSetChanged();
	}

	public void addList(List list) {
		this.data.addAll(list);
		this.notifyDataSetChanged();
	}

}